
module.exports = (app) => {
  const BaseService = require("./base")(app);
  const modelList = require("../../model")(app);
  return class ProjectService extends BaseService {
    async getModelList() {
      return modelList
    }
    getList({ projKey }) {
      const projectList = []
      modelList.forEach(item => {
        const { project } = item
        if (projKey && !project[projKey]) {
          return 
        }
        for (const key in project) {
          projectList.push(
            project[key],
          )
        }
      })

      return projectList
    }
    get(projKey) {
      let projConfig
      modelList.forEach(item => {
        if (item.project[projKey]) {
          projConfig = item.project[projKey]
        }
      })

      return projConfig
    }
  };
};
